Also, both functions guarantee that the destination will be NUL-terminated as long as the size is at least one (you can't put anything into a zero-length buffer).
此外,只要目标的大小至少为1,两个函数都保证目标将以NUL结尾(您不能将任何内容放入零长度的缓冲区)。
In general, one useful approach is to pass a length to the 'counted string' function one smaller than the size of the buffer and then explicitly assign zero to the last character in the buffer.
通常,一种有用的方法是,向“计数字符串”函数传递比缓冲区大小小一的长度,然后将零显式赋给缓冲区中的最后一个字符。
应用推荐